package com.yunxiang.controller;


import com.jfinal.core.Controller;
import com.jfinal.weixin.sdk.api.SnsAccessToken;
import com.jfinal.weixin.sdk.api.SnsAccessTokenApi;
import com.jfinal.weixin.sdk.utils.HttpUtils;

public class LoginController extends Controller {

	public void getOpenId(){
		String AuthorizeURL = SnsAccessTokenApi.getAuthorizeURL("wx0b9984df76410893", "http://88571a87.ngrok.io/youin_chat/login/redirectUrl","123456",false );
		System.out.println(AuthorizeURL);
		String res = HttpUtils.get(AuthorizeURL);
		System.out.println("得到的结果"+res);
		renderJson(res);
	}
	public void redirectUrl(){
		String code = getPara("code");
		System.out.println(code);
		SnsAccessToken token =  SnsAccessTokenApi.getSnsAccessToken("wx0b9984df76410893", "b06a7c50ddb99106dcf354bbcee5cb6f", code);
		//String accessToken = token.getAccessToken();
		String openid = token.getOpenid();
		System.out.println(openid);
		render("/reg.html");
	}
}
